#include "robot.hpp"

Robot::Robot(Serial* serial)
{
	this->serial = serial;
}

Robot::~Robot()
{
	serial->close();
}

bool Robot::connect()
{
	return serial->open();
}

bool Robot::cmd(uint8_t pan, uint8_t tilt, uint8_t zoom, uint8_t fire)
{
	cbus.x = pan;
	cbus.y = tilt;
	cbus.z = zoom;
	cbus.f = fire;
	CBus_PackUp(&cbus, cbuf);
	return serial->tx(cbuf, CBUS_BUF_LEN)== CBUS_BUF_LEN;
}
